<style type="text/css">
<!--
.style5 {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 12px;
	font-weight: bold;
}
body,td,th {
	color: #CCCCCC;
}
body {
	background-color: #000000;
}
a:link {
	color: #CCCCCC;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #CCCCCC;
}
a:hover {
	text-decoration: underline;
	color: #666666;
}
a:active {
	text-decoration: none;
	color: #999999;
}
.style7 {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: xx-large;
}
.style8 {font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;}
.style9 {color: #FF0000}
-->
</style>
<p align="center" class="style7"><em>blo</em><strong><u>k</u></strong></p>
<table width="562" border="0" align="center">
  <tr>
    <td width="556"><span class="style5">blok</span><span class="style8"> is simply the most simple script on the net... it features a lite chat system that enables administrators and basically anyone with any knowledge of how a computer works, to upload a simple zip file's contents to a space of about 1/2 a megabyte on any server, utilizing one SQL database. This asynchronous chat system is good for example in emergency situations that require fast deployment of simple chat based software to post ideas and updates and exchange them communally. </span><span class="style5">
      <hr />
    </span></td>
  </tr>
  <tr>
    <td bgcolor="#000000" class="style5"><div align="center"><a href="http://www.kdev.org/main/forum_viewforum.php?11">bloK Forum</a> </div></td>
  </tr>
  <tr>
    <td class="style5"><hr /></td>
  </tr>
</table>
<p align="center" class="style5">
  <?
// 2006 kDev.org Webware Technologies
// http://www.kdev.org
// Version 0.1
// bloK - Basic Asynchronous Posting System
// This system is best used on private networks and websites that need not be moderated too heavily for the quick deployment of a // small simple script that enables users to interact quickly and reply.
// Database connection
include("connect.php");
// choose language (uk,dk,spanish)
$language = "us";
$time_now = time();
// time to set state to NEW in seconds
$new_state = "432000";
if ($language == "us"){
	$create = "Message Successfully Entered!";
	$form_error = "kDev.org";
	$by = "by";
	$replys = "Replies";
	$no_threads = "There are no threads.";
	$submit_thread = "Submit a reply.";
	$no_replys = "No replies.";
	$n_thread = "Create new thread";
	$create_reply = "You have created a reply.";
	$name_t = "Name";
	$email_t = "Email";
	$link_t = "Link";
	$topic_t = "Topic";
	$text_t = "Text";
	$new = "NEW";
	$search_t = "Search";
	$no_result = "No result.";
	$threads = "Threads";
	$back = "Back";
	$subject_mail = "There is a new reply to the thread you participate in at kDev.org";
	$mail_body = "has replied to the thread";
	$valid_email = "Please type a valid email adress";
	$valid_link = "Please type a valid link or none";
}
?>
</p>
<link rel="stylesheet" href="stylesheet.css" type="text/css">
<table width="54%" height="43%" border="0" align="center" cellpadding="0" cellspacing="4">
<tr>
<td height="43" colspan="2" valign="top" class="style5">
  
    <div align="center">
      <?php
if ($create_thread) {
	echo "<center><form name='threadform' method='post' action=''>
  <div align='left'>
    <table width='200' border='0'>
      <tr>
        <td>$name_t:</td>
        <td><input type='text' name='name'></td>
      </tr>
      <tr>
        <td>$email_t:</td>
        <td><input type='text' name='email'></td>
      </tr>
      <tr>
        <td>$link_t:</td>
        <td><input type='text' name='link'></td>
      </tr>
      <tr>
        <td>$topic_t:</td>
        <td><input type='text' name='topic'></td>
      </tr>
      <tr>
        <td>$text_t:</td>
        <td><textarea cols='20' rows='5' name='text'></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div align='right'>
          <input type='submit' name='send' value='Send'>
        </div></td>
      </tr>
    </table>
    </div>
</form></center>";
}
if ($send){
        	if ($email != ""){
				$email=trim($email);
				$s=substr_count($email,"@");
				$d=substr_count($email,".");
				$m=substr_count($email," ");
				if ($s==1 && $d>=1 && $m==0) {
        			$email_ok = "ok";        		
        		} else {
					echo "$valid_email...<br>";
				}
        	} else {
			echo "$valid_email...<br>";
			}
				if ($link != ""){
				$link = trim($link);
				$link = ereg_replace("http://", "", $link);
				$s=substr_count($link,"http://");
				$d=substr_count($link,".");
				if ($s==0 && $d>=1){
					$link_ok = "ok";
				} else {
				echo "$valid_link...<br>";
				}
			} else {
				$link_ok = "ok";
			}
	if ($name && $email_ok && $link_ok && $topic && $text) {
		$time = time();
		// Removes certain html tags
		$text = strip_tags($text, '<b><a><i><u>');
		$topic = strip_tags($topic);
		$name = strip_tags($name);
		mysql_query("insert into forum (name,email,link,topic,text,time) values ('$name', '$email', '$link', '$topic', '$text', '$time')");
		echo "$create";
	} else {
		echo "$form_error";
	}
}
//list threads
if (!$create_thread && !$show_thread && !$search) {
	$result = mysql_query("SELECT * FROM forum WHERE thread like '0' ORDER BY time DESC");
	if (mysql_num_rows($result)>0){
		while ($row = mysql_fetch_array($result)) {
			$time = date("d-m-y H:i:s",$row[time]);
			$result1 = mysql_query("SELECT * FROM forum where thread = '$row[id]' ORDER BY time DESC");
			$count = mysql_num_rows($result1);
			$row1 = mysql_fetch_array($result1);
			echo "<a href='?view=index.php&show_thread=$row[id]'>$time - <b>$row[topic]</b> $by <b>$row[name]</b></a> - $replys: $count";
			if (($time_now - $row1[time])< $new_state){
				echo " <b>$new</b>";
			}
			echo "<br>";
		}
	} else {
		echo "$no_threads";
	}
}
if ($show_thread or $show_reply) {
	$result = mysql_query("SELECT * FROM forum where id = '$show_thread' ORDER BY time DESC");
	$row = mysql_fetch_array($result);
	$time = date("d-m-y H:i:s",$row[time]);
	echo "<table width='100%' border='1' bordercolor='#000000' cellpadding='0' cellspacing='0'>";
	echo "<tr><td>";
	echo "<table width='100%' border='0' cellpadding='0' cellspacing='4'>";
	echo "<tr><td>";
	echo "<b>$time - $row[topic] $by <a href='mailto:$row[email]'>$row[name]</a> | <a target='_new' href='http://$row[link]'>www</a></b>";
	if (($time_now - $row[time])< $new_state){
		echo " <b>$new</b>";
	}
	echo "</td></tr><tr><td>";
	echo "$row[text]";
	echo "</td></tr>";
	echo "</td></tr><tr><td align='right'>";
	echo "<a href='index.php?reply=$row[id]'><b>$submit_thread</b></a>";
	echo "</td>";
	echo "</table>";
	echo "</td></tr></table>";
	$result = mysql_query("SELECT * FROM forum where thread = '$show_thread' ORDER BY time ASC");
	if (mysql_num_rows($result)>0){
		$i = "<img src='images/forum/corner.gif' width='10' height='11' align='center'><img src='images/forum/space.gif' width='10' height='11' align='center'>";
		while ($row = mysql_fetch_array($result)){
			$time = date("d-m-y H:i:s",$row[time]);
			echo "$i <a href='index.php?show_reply=$row[id]&show_thread=$row[thread]'>$time - <b>$row[name]</b></a>";
			if (($time_now - $row[time])< $new_state){
				echo " <b>$new</b>";
			}
			echo "<br>";
		}
	} else {
		echo "$no_replys";
	}
	if ($show_reply){
		$result = mysql_query("SELECT * FROM forum where id = '$show_reply'");
		$row = mysql_fetch_array($result);
		$time = date("d-m-y H:i:s",$row[time]);
		echo "<table width='100%' border='1' bordercolor='#CCCCCC' cellpadding='0' cellspacing='0'>";
		echo "<tr><td>";
		echo "<table width='100%' border='0' cellpadding='0' cellspacing='4'>";
		echo "<tr><td>";
		echo "<b>$time - $by <a href='mailto:$row[email]'>$row[name]</a> | <a target='_new' href='http://$row[link]'>www</a></b>";
		if (($time_now - $row[time])< $new_state){
			echo " <b>$new</b>";
		}
		echo "</td></tr><tr><td>";
		echo "$row[text]";
		echo "</td></tr>";
		echo "</td></tr><tr><td align='right'>";
		echo "</td>";
		echo "</table>";
		echo "</td></tr></table>";
	}
}

if ($reply){
	echo "<br><form name='threadform' method='post' action=''>
	<table width='200' border='0'>
      <tr>
        <td>$name_t:&nbsp;</td>
        <td><input type='text' name='name'></td>
      </tr>
      <tr>
        <td>$email_t:</td>
        <td><input type='text' name='email'></td>
      </tr>
      <tr>
        <td>$link_t:</td>
        <td><input type='text' name='link'></td>
      </tr>
      <tr>
        <td>$text_t:</td>
        <td><textarea name='text'></textarea></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><div align='right'>
          <input type='submit' name='send_reply' value='Send'>
        </div></td>
      </tr>
    </table>
	</form>";
}
if ($send_reply){
        	if ($email != ""){
				$email=trim($email);
				$s=substr_count($email,"@");
				$d=substr_count($email,".");
				$m=substr_count($email," ");
				if ($s==1 && $d>=1 && $m==0) {
        			$email_ok = "ok";        		
        		} else {
					echo "$valid_email...<br>";
				}
        	} else {
			echo "$valid_email...<br>";
			}
						if ($link != ""){
				$link = trim($link);
				$link = ereg_replace("http://", "", $link);
				$s=substr_count($link,"http://");
				$d=substr_count($link,".");
				if ($s==0 && $d>=1){
					$link_ok = "ok";
				} else {
				echo "$valid_link...<br>";
				}
			} else {
				$link_ok = "ok";
			}
	if ($name && $email_ok && $link_ok && $text) {
	// sends an email to all members of the thread
		$result = mysql_query("select * from forum where id like '$reply'");
		while ($row = mysql_fetch_array($result)){
			mail("$row[email]", "$subject_mail", "$name $mail_body:\n\n$row[text]\n\n", "");
		}
		$result2 = mysql_query("select * from forum where thread like '$reply' AND email not like '$email' GROUP BY email");
		while ($row = mysql_fetch_array($result2)){
			mail("$row[email]", "$subject_mail", "$name $mail_body:\n\n$row[text]\n\n", "");
		}
		$time = time();
		$text = strip_tags($text, '<b><a><i><u>');
		$name = strip_tags($name);
		mysql_query("insert into forum (name,email,link,thread,text,time) values ('$name', '$email', '$link', '$reply', '$text', '$time')");
		echo "$create_reply";
	} else {
		echo "$form_error";
	}
}
?>
      <hr />
    </div></td>
</tr>
<tr valign="top">
<td width="50%" height="25" class="style5">
  
    <div align="center">
      <?
echo "<center><a href='index.php?create_thread=yes'><b>$n_thread</b></a>";
echo " | ";
echo "<a href='index.php'><b>$back</b></a></center>";
?>
      <hr />
    </div></td>
<td width="50%" align="right" class="style5">
  <div align="center">
    <?
$result = mysql_query("select * from forum WHERE thread like '0'");
$count = mysql_num_rows($result);
echo "<b>$threads: $count</b>";
$result = mysql_query("select * from forum WHERE thread not like '0'");
$count = mysql_num_rows($result);
echo " | ";
echo "<b>$replys: $count</b>";
// Close MySQL connection
mysql_close();
?>
    <hr />
  </div></td>
</tr>
</table>
<p align="center" class="style5">&copy;2006 kDev.org - blok v.0.9</p>
